// 预加载脚本 (preload.js)
const { contextBridge, ipcRenderer } = require("electron");

const ReadFile = async (path) => {
  return ipcRenderer.invoke("on-read-file-no-dialog-event", path);
};

// 设置属性
const SetPos = (data) => {
  ipcRenderer.invoke("on-set-pos-event", data);
};

const SetTop = (data) => {
  ipcRenderer.invoke("on-set-top-event", data);
};

contextBridge.exposeInMainWorld("electronAPI", {
  onMouseDownMsg: (callback) => {
    ipcRenderer.on("global-mouse-down", callback);
  },
  onMouseUpMsg: (callback) => {
    ipcRenderer.on("global-mouse-up", callback);
  },
  ReadFile,
  SetTop,
  SetPos,
  onSettingMsg: (callback) => {
    ipcRenderer.on("setting-msg", callback);
  },
});
